#ifndef _BRIEF_H_
#define _BRIEF_H_


#include <opencv2/opencv.hpp>
#include "FastWrapper.hpp"
#include "anms.h"
#include "Feature.hpp"
using namespace cv;


namespace markerAR
{
    
class BRIEF
{
public:
    BRIEF(){};
    BRIEF(int threshold, int npoints);
    ~BRIEF();
    void detect(const Mat&img, vector<KeyPoint>&kpts, const Mat&mask=Mat());
    void detect(const Mat&img, vector<Feature*>&fts, const Mat&mask=Mat());
    void detect(const vector<Mat>&allImgs, vector<vector<KeyPoint>>&allKpts, int npoints, float scale, int levelNum);
    void compute(const Mat&img, vector<KeyPoint>&kpts, Mat &desp);
    void computeImpl(const Mat& image, std::vector<Feature*>& fts) const;
    void compute(const Mat&img, vector<Feature*>&fts) const;
    void knnMatch(const Mat&queryDesp, const Mat&trainDesp, vector<vector<DMatch>> &dmatches, int k);
    void compute(const vector<Mat>&allImgs, vector<vector<KeyPoint>>&allKpts, vector<Mat> &allDesps);
    void compute(const vector<Mat>&allImgs, vector<vector<Feature*>>&allKpts);
    void detect(const vector<Mat>&allImgs, vector<vector<Feature*>>&allKpts, int npoints,float scale, int levelNum);

    void operator()(const Mat&img,const Mat&mask,std::vector<KeyPoint>&kpts,cv::Mat&desp);
    void operator()(const Mat&img,const Mat&mask,std::vector<Feature*>&fts);
private:
    void detect(const Mat&img, vector<KeyPoint>&kpts, const int npoints,const Mat&mask = Mat());
    BriefDescriptorExtractor extractor;
    FastWrapper fd;
    Ptr<DescriptorMatcher> binaryMatcher;
    ANMS anms;
    int npoints;
    cv::Size imgSize;
};
}

#endif